/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef PLJAVA_ATTRIBUTE_EXCEPTION_TABLE_H
#define PLJAVA_ATTRIBUTE_EXCEPTION_TABLE_H

#include <PLJavaFile.h>

namespace PLSDK {

/**
 * Table with the exception table.
 */
class PLJavaAttributeExceptionTable {
public:
    /**
     * Constructor.
     *
     * @param newStartPc The start point of the exception in the instruction code.
     * @param newEndPc The end point of the exception in the instruction code.
     * @param newHeaderPc The value of the newHeaderPc item indicates the start of the exception handler.
     * @param newCatchType If the value of the catch_type item is nonzero, it must be a valid index
     * into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info
     * structure representing a class of exceptions that this exception handler is designated to catch.
     * This class must be the class Throwable or one of its subclasses. The exception handler will be
     * called only if the thrown exception is an instance of the given class or one of its subclasses.
     */
    PLJavaAttributeExceptionTable(u2 newStartPc, u2 newEndPc, u2 newHeaderPc, u2 newCatchType);
    /**
     * The start point of the exception in the instruction code.
     *
     * @return The start point.
     */
    inline u2 startPc();
    /**
     * The end point of the exception in the instruction code.
     *
     * @return The end point.
     */
    inline u2 endPc();
    /**
     * The value of the newHeaderPc item indicates the start of the exception handler.
     *
     * @return The start point.
     */
    inline u2 headerPc();
    /**
     * Get the catch type.
     *
     * @return The catch type.
     */
    inline u2 catchType();
private:
    u2 m_startPc;
    u2 m_endPc;
    u2 m_headerPc;
    u2 m_catchType;
};

u2 PLJavaAttributeExceptionTable::startPc() {
    return m_startPc;
}

u2 PLJavaAttributeExceptionTable::endPc() {
    return m_endPc;
}

u2 PLJavaAttributeExceptionTable::headerPc() {
    return m_headerPc;
}

u2 PLJavaAttributeExceptionTable::catchType() {
    return m_catchType;
}

}

#endif
